clc;
clear;

%% 目标数组 [1, 4, 6, 16, 17, 1, 10, 13, 16, 6, 9, 10, 12, 8, 5, 3, 18, 14]
index0 = [6, 1, 0;
    0, 0, 0;
    0, 0, 16;
    0, 2, 0;
    0, 0, 15;
    10, 0, 3;
    0, 0, 0;
    0, 0, 14;
    11, 0, 0;
    12, 7, 0;
    0, 0, 0;
    0, 13, 0;
    8, 0, 0;
    0, 0, 18;
    0, 0, 0;
    4, 0, 9;
    5, 0, 0;
    17, 0, 0];

[rows, cols] = find(index0);
targetArray = zeros(1, size(rows,1));
for i = 1:size(rows,1)
    targetArray(index0(rows(i), cols(i))) = rows(i);
end
disp(targetArray);